<style lang="less">
  .searchb {
    width: 80vw;
    margin-left: 5vw;
  }

  .search {
    width: 18vw;
  }

  .search_date {
    width: 29vw;
  }
  .tongji{
    width: 80vw;
    font-size: 20px;
    padding-left:40px;
  }
  .uploagdialog{
    .el-dialog__body{
    margin: 0px;
    padding: 0px;
    }
    .el-dialog__header{
      margin: 0px;
      padding: 0px;
    }
  }
  .printfangda{
    font-size: 18px;
  }
  .printfangda1{
    font-size: 25px;
  }
</style>
<template>
  <div >
    <div class="qrcode" ref="qrCodeUrl"></div>
    <el-collapse v-model="activeNames">
      <el-collapse-item  name="1">
        <template slot="title">
          <p style="margin-left: 3vw;font-size: 1vw;">上料操作台</p>
        </template>

        <el-form class="searchb"  size="small" ref="form" :model="form" :inline="true">
          <el-form-item label="颜色" class="search">
            <el-input v-model="form.color"></el-input>
          </el-form-item>
          <el-form-item label="色号" class="search">
            <el-input v-model="form.color_code"></el-input>
          </el-form-item>
          <el-form-item label="节号" class="search">
            <el-input v-model="form.batch_name"></el-input>
          </el-form-item>
          <el-form-item label="优化号" class="search">
            <el-input type="textarea" v-model="form.yhh_id"></el-input>
          </el-form-item>
          <el-form-item label="创建人" class="search">
            <el-input v-model="form.creator_name"></el-input>
          </el-form-item>
          <el-form-item label="送料人" class="search">
            <el-input v-model="form.feed_name"></el-input>
          </el-form-item>
          <el-form-item label="收料人" class="search">
            <el-input v-model="form.reap_name"></el-input>
          </el-form-item>
          <el-form-item label="车间" class="search">
            <el-input v-model="form.workshop"></el-input>
          </el-form-item>
          <el-form-item label="状态" class="search">
            <el-select style="width: 10vw;" v-model="form.status" placeholder="请选择">
              <el-option  v-for="item in status_options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备料" class="search">
            <el-select v-model="form.stock" filterable placeholder="请选择">
              <el-option  v-for="(item,i) in stock_options" :key="i" :label="item" :value="i">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="时间类别" class="search">
            <el-select style="width: 10vw;" v-model="form.time_category" placeholder="请选择">
              <el-option  v-for="(item,key) in time_categorys" :key="key" :label="item" :value="key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="时间" class="search_date">
            <el-date-picker style="width: 22vw;" v-model="form.time" type="datetimerange" range-separator="至" start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item>
<!--          <el-form-item label="完成时间" class="search_date">
            <el-date-picker style="width: 22vw;" v-model="form.accomplish_time" type="datetimerange" range-separator="至" start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item> -->

        </el-form>
        <el-form class="searchb"  size="small" ref="form" :model="form" :inline="true">
          <el-form-item>
            <el-button type="primary" @click="import_data" v-show="production_dispatch_control">导入计划</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="inquire_data">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="delete_data" v-show="production_dispatch_control">删除</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="execute_data" v-show="production_execut_properly">执行工作台</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="print_data" >打印</el-button>
          </el-form-item>
          <el-form-item>
            <el-link @click="cleandata" type="primary">重置</el-link>
          </el-form-item>
          <el-form-item v-show="production_dispatch_accomplish" style="margin-left:50px;">
              <el-button type="primary" @click="alfter_machine_number">修改机台号</el-button>
          </el-form-item>
          <el-form-item label="机台号" v-show="production_dispatch_accomplish">
              <el-input v-model="machine_number"></el-input>
          </el-form-item>
        </el-form>
      </el-collapse-item>
    </el-collapse>
    <div class="tongji">总任务{{countdata.zongshu}}个。已完成{{countdata.wanchengcount}}个。未完成{{countdata.weiwanchengcount}}个。</div>
    <el-table v-loading="loading" :data="tableData" :span-method="objectSpanMethod" :cell-style="cellStyleShou"
      :header-cell-style="headerCellStyle" ref="formtable"
       @sort-change = "sortdata"
       border
      >
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column prop="status_name" label="状态">
      </el-table-column>
      <el-table-column
        prop="stock_name"
        label="备料"
        width="70"
        >
      </el-table-column>
      <el-table-column prop="color" label="颜色">
      </el-table-column>
      <el-table-column prop="color_code" label="色号" width="60">
      </el-table-column>
      <el-table-column
        label="节号"
        width="110">
       <template slot-scope="data">
           <div v-for="b in data.row.batch_names">{{b}}</div>
        </template>
      </el-table-column>
      <el-table-column prop="go_on" label="接龙" width="60">
      </el-table-column>
      <el-table-column prop="yhh_id" label="优化号">
      </el-table-column>
      <el-table-column prop="amount" label="数量" width="60">
      </el-table-column>
      <el-table-column prop="count" label="总数" width="60">
      </el-table-column>
      <el-table-column prop="heap_number" label="堆号" width="60">
      </el-table-column>
      <el-table-column prop="machine_number" label="机台号" width="70">
      </el-table-column>
     <el-table-column prop="remark" label="备注">
      </el-table-column>
      <el-table-column prop="workshop" label="车间" width="60">
      </el-table-column>
      <el-table-column
        prop="guige"
        label="规格"
        width="60"
        >
      </el-table-column>
      <el-table-column prop="square" label="平方" width="80">
      </el-table-column>
      <el-table-column prop="thickness" label="厚度" width="60">
      </el-table-column>
      <el-table-column prop="creator_name" label="创建人">
      </el-table-column>
      <el-table-column prop="feed_name" label="送料人" width="70">
      </el-table-column>
      <el-table-column prop="reap_name" label="收料人" width="70">
      </el-table-column>
      <el-table-column prop="ctime" width="170" label="创建时间">
      </el-table-column>
      <el-table-column
      width="170"
      prop="request_time"
      label="请求时间"
      sortable="custom">
      </el-table-column>
      <el-table-column prop="accomplish_time" width="170"  label="完成时间">
      </el-table-column>
      <el-table-column  prop="productive_time" width="170" label="实际计划下单时间">
      </el-table-column>
    </el-table>
    <el-pagination
      style="text-align: right;"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
      :current-page="pagintion.page"
      :page-size="pagintion.page_size"
      :page-sizes="pagesizes"
      layout="total, prev, pager, next, jumper ,sizes"
      :total="pagintion.total">
    </el-pagination>
    <div class="uploagdialog">
      <el-dialog  :visible.sync="uploadVisible" width="30%">
        <uploadFile @close="closeupload"></uploadFile>
      </el-dialog>
    </div>
    <el-dialog title="打印" :visible.sync="printVisible" width="39.5%">
      <el-button type="primary" v-print="prinobject" style="margin-left:5vw;" >确定打印</el-button>
      <div style="margin-top:20px;"></div>
      <div id="printMe" >
        <div v-for="(table,k) in tableDataprints">
          <div style="page-break-after:always" v-if="table[0].ishuanye && k !=0"></div>
          <div style="margin-top:33px;" v-if="k != 0"></div>
          <el-table  size="mini" v-loading="loadingprint" :data="table" :span-method="objectPrintSpanMethod" :cell-style="cellpirntStyleShou"
            :header-cell-style="headerCellStyle" ref="formtable"
            @sort-change = "sortdata"
            border
            >
            <el-table-column prop="xuhao" label="序号" width="50">
            </el-table-column>
            <el-table-column prop="color" label="颜色" width="120">
              <template slot-scope="data">
                <div class="printfangda">{{data.row.color}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="数量" width="60">
              <template slot-scope="data">
                <div class="printfangda">{{data.row.amount}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="count" label="总数" width="70">
              <template slot-scope="data">
                <div class="printfangda1">{{data.row.count}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="heap_number" label="堆号" width="60">
              <template slot-scope="data">
                <div class="printfangda1">{{data.row.heap_number}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="workshop" label="车间" width="50">
            </el-table-column>
            <el-table-column prop="guige"label="规格" width="70">
              <template slot-scope="data">
                <div class="printfangda">{{data.row.guige}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="thickness" label="厚度" width="50">
              <template slot-scope="data">
                <div class="printfangda" >{{data.row.thickness}}</div>
              </template>
            </el-table-column>
            <el-table-column prop="remark" label="备注" width="80">
            </el-table-column>
            <el-table-column
              label="二维码"
              width="100"
              align="right">
              <template slot-scope="data">
                <div class="qrcode"  :ref="'qrCodeUrl'+data.row.id" v-if="data.row.isshou" :id="'qrCodeUrl'+data.row.id"></div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import MainVue from "./MainVue.vue";
  import 'boqii-modal'
  import Axios from 'axios';
  import Vue from 'vue';
  import uploadFile from './upload_file/upload_file'
  import router from '../router/index';
  import QRCode from 'qrcodejs2'
  import {
    getList,
    execute_data,
    delete_data,
    post_machine_number
  } from '@/request/api';


  export default {
    components: {
      MainVue: MainVue,
      uploadFile : uploadFile
    },
    data() {
      return {
        uploadVisible:false,
        printVisible:false,
        countdata:{zongshu:'',wanchengcount:'',weiwanchengcount:''},
        sortdatas:{status_name:"",ctime:"",request_time:""},
        activeNames: ['1'],
        pagesizes:[10,20,30,40,50],
        pagintion:{
          total:0,
          page_size:10,
          page:1,
        },
        loading: false,
        loadingprint: false,
        fileList: [],

        status_options: [
          {
            value: '',
            label: ''
          },{
            value: '2',
            label: '未送料'
          }, {
              value: '3',
              label: '请求送料'
          }, {
              value: '4',
              label: '送料中'
          }, {
              value: '5',
              label: '已收料'
          },
        ],
        form: {
          color: '',
          color_code: '',
          batch_name: '',
          yhh_id: '',
          time_category: 'plmd.ctime',
          time: ['2021-06-30T16:00:00.000Z', ''],
          // accomplish_time: ['', ''],
          creator_name: '',
          workshop: '',
          feed_name: '',
          reap_name: '',
          status: '',
          stock:''
        },
        time_categorys:{'plmd.ctime':'创建时间',
          'plmd.accomplish_time':'完成时间',
          'batch.productive_time':'实际计划下单时间'
        },
        objectSpandata: {
          1: 2
        },
        priobjectSpandata:{},
        columnIndexs: [0, 1, 9, 10,11,17, 18, 19, 20, 21,22],
        columnprintIndexs: [0,3,4,9],
        tableData: [],
        tableDataprint:[],
        tableDataprints:[],
        production_dispatch_control:false,
        production_execut_properly:false,
        production_dispatch_accomplish:false,
        qrcodes:{},
        stock_options:{'':'','0':'未备料','1':'已备料'},
        prinobject:{
          id:"printMe",
          popTitle:"备料指令",
          extraCss:""
        },
        machine_number:'',
      }
    },
    mounted() {
      var timestamp = Date.parse(new Date())/1000;
      this.form.time = [this.getdate(timestamp-432000),this.getdate(timestamp+86400)];
      // this.form.time = [this.getdate(timestamp-100432000),this.getdate(timestamp+86400)];
      this.getplmlist();
    },
    methods: {
      closeupload(){
        this.uploadVisible = false;
      },
      cleandata(){
        this.form = {
          color: '',
          color_code: '',
          batch_name: '',
          yhh_id: '',
          time_category: 'plmd.ctime',
          time: ['', ''],
          // accomplish_time: ['', ''],
          creator_name: '',
          workshop: '',
          feed_name: '',
          reap_name: '',
          status: ''
        };
        var timestamp = Date.parse(new Date())/1000;
        this.form.time = [this.getdate(timestamp-432000),this.getdate(timestamp+86400)];
        this.getplmlist();
      },
      sortdata(val){
        this.sortdatas.status_name = '';
        this.sortdatas.ctime = '';
        this.sortdatas.request_time='';
        if(val.order == 'ascending'){
          val.order = 'asc';
        }else if(val.order == 'descending'){
          val.order = 'desc';
        }else{
          val.order = '';
        }
        this.sortdata[val.prop] = val.order;
        this.getplmlist();
      },
      handleSizeChange(val) {
        this.pagintion.page_size = val;
        this.getplmlist();
      },
      handleCurrentChange(val){
        this.pagintion.page = val;
        this.getplmlist();
      },
      inquire_data() {
        this.getplmlist();
      },
      print_data(){
        this.tableDataprints = [];
        this.printVisible =true;
        this.loadingprint = true;
        var param = {};
        param.page = 0;
        param.pagesize = 1000;
        param['searchParams[creator_name]'] = this.form.creator_name;
        param['searchParams[feed_name]'] = this.form.feed_name;
        param['searchParams[reap_name]'] = this.form.reap_name;
        param['searchParams[status]'] = this.form.status;
        param['searchParams[time_filter][time_category]'] = this.form.time_category;
        param['searchParams[time_filter][start_time]'] = this.form.time[0];
        param['searchParams[time_filter][end_time]'] = this.form.time[1];
        // param['searchParams[ctime_start]'] = this.form.ctime[0];
        // param['searchParams[ctime_end]'] = this.form.ctime[1];
        // param['searchParams[accomplish_time_start]'] = this.form.accomplish_time[0];
        // param['searchParams[accomplish_time_end]'] = this.form.accomplish_time[1];
        param['searchParams[color_color]'] = this.form.color;
        param['searchParams[color_code]'] = this.form.color_code;
        param['searchParams[batch_name]'] = this.form.batch_name;
        param['searchParams[yhh_ids]'] = this.form.yhh_id;
        param['searchParams[workshop]'] = this.form.workshop;
        param['searchParams[wanchengcount]'] = 'wanchengcount';
        if(this.sortdatas.status_name != ''){
          param['searchParams[status_sort]'] = this.sortdatas.status_name;
        }
        if(this.sortdatas.ctime != ''){
          param['searchParams[ctime_sort]'] = this.sortdatas.ctime;
        }
        if(this.sortdatas.request_time != ''){
          param['searchParams[request_time_sort]'] = this.sortdatas.request_time;
        }
        if(this.form.stock != ""){
          param['searchParams[stock]'] = this.form.stock;
        }
        getList(param).then(res => {
          this.loadingprint = false;
          this.setdata(res.msg.instruct,this.tableDataprint,2);
          var count = 0;
          var dancount = 0;
          var xuhao = 0;
          console.log(this.priobjectSpandata);
          for(var i = 0; i < this.tableDataprint.length; i++){
            var data = this.tableDataprint[i];

            if(data.isshou){
              xuhao ++
              var longc = count + this.priobjectSpandata[dancount]+2;
              if(longc > 30){
                data.ishuanye = true;
                count = 0;
              }
              count = count+2;
              if(this.priobjectSpandata[dancount] == 1){
                count = count + 2;
              }else if(this.priobjectSpandata[dancount] == 2){
                count ++;
              }
              // console.log(count%16);
              data.xuhao = xuhao;
              // console.log(data.yhh_id+"=============="+count);
              this.tableDataprints.push([]);
              
            }
            if(data.color != null && data.color.length > 5){
              count = count + 2;
            }else{
              count++;
            }
            // count++;
            dancount++;
            this.tableDataprints[this.tableDataprints.length-1].push(data); 
          }
          this.$nextTick(() => {
            for(let i = 0;i < this.tableDataprint.length;i++){
              if(this.tableDataprint[i].isshou){
                this.creatQrCode(this.tableDataprint[i].id);
              }
            }
        });
        }, err => {
          this.loadingprint = false;
        })
      },
      creatQrCode(id) {
        
        if(this.qrcodes[id] != undefined){
          
          this.qrcodes[id].innerHTML = '';
          this.qrcodes[id].clear();
        }

        var qrcode = new QRCode(document.getElementById('qrCodeUrl'+id), {
            text: id, // 需要转换为二维码的内容
            width: 80,
            height: 80,
            colorDark: '#000000',
            colorLight: '#ffffff',
            correctLevel: QRCode.CorrectLevel.H
        })
        this.qrcodes[id] = qrcode;
    },
      //删除任务
      delete_data() {
        var datas = this.$refs.formtable.selection;
        var param = {};
        var plmd_ids = [];
        for (var i = 0; i < datas.length; i++) {
          plmd_ids[i] = datas[i].id;
          if(datas[i].status != 2){
             this.$confirm('任务'+datas[i].id+'不是未送料，不能删除')
                 .then(_ => {
                   done();
                 })
                 .catch(_ => {});
             return;
          }

        }
        param.plmd_ids = plmd_ids;

        delete_data(param).then(res => {
          this.getplmlist();
        })

      },
      //加入执行台
      execute_data() {
        router.replace({
            path: '/production_load_material_workbench',
        });
      },
      //导入文件
      import_data() {
        this.uploadVisible = true;
      },
      //设置表格style              
      cellStyleShou(row, column, rowIndex, columnIndex) {
        var style = {};
        style.color = 'black';
        return style;
      },
      //设置打印表格二维码居上style
      cellpirntStyleShou(row, column, rowIndex, columnIndex) {
        var style = {};
        style.color = 'black';
        if(row.columnIndex == 9){
          style["vertical-align"] = 'top';
        }
        return style;
      },
      //设置表头style
      headerCellStyle(row, rowIndex) {
        return {
          background: '#eee',
          color: '#606266'
        };
      },
      //合并单元格
      objectSpanMethod({row,column,rowIndex,columnIndex}) {
        if (this.columnIndexs.indexOf(columnIndex) > -1) {
          for (var key in this.objectSpandata) {
            if (rowIndex == key) {
              if (this.objectSpandata[key] > 1) {

                return {
                  rowspan: this.objectSpandata[key],
                  colspan: 1
                };
              } else {
                return;
              }

            }
          }
        }
        if (this.columnIndexs.indexOf(columnIndex) > -1) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      },
      //打印的合并单元格
      objectPrintSpanMethod({row,column,rowIndex,columnIndex}) {
        if (this.columnprintIndexs.indexOf(columnIndex) > -1) {
          if (rowIndex == 0) {
            return {
              rowspan: 100,
              colspan: 1
            };
          }
          // for (var key in this.objectSpandata) {
          //   if (rowIndex == key) {
          //     if (this.objectSpandata[key] > 1) {
          //       return {
          //         rowspan: this.objectSpandata[key],
          //         colspan: 1
          //       };
          //     } else {
          //       return;
          //     }
          //   }
          // }
        }
        if (this.columnprintIndexs.indexOf(columnIndex) > -1) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      },
      //获取数据
      getplmlist() {
        this.loading = true;
        var param = {};
        param.page = this.pagintion.page-1;
        param.pagesize = this.pagintion.page_size;
        param['searchParams[creator_name]'] = this.form.creator_name;
        param['searchParams[feed_name]'] = this.form.feed_name;
        param['searchParams[reap_name]'] = this.form.reap_name;
        param['searchParams[status]'] = this.form.status;
        param['searchParams[time_filter][time_category]'] = this.form.time_category;
        param['searchParams[time_filter][start_time]'] = this.form.time[0];
        param['searchParams[time_filter][end_time]'] = this.form.time[1];
        // param['searchParams[ctime_start]'] = this.form.ctime[0];
        // param['searchParams[ctime_end]'] = this.form.ctime[1];
        // param['searchParams[accomplish_time_start]'] = this.form.accomplish_time[0];
        // param['searchParams[accomplish_time_end]'] = this.form.accomplish_time[1];
        param['searchParams[color_color]'] = this.form.color;
        param['searchParams[color_code]'] = this.form.color_code;
        param['searchParams[batch_name]'] = this.form.batch_name;
        param['searchParams[yhh_ids]'] = this.form.yhh_id;
        param['searchParams[workshop]'] = this.form.workshop;
        param['searchParams[wanchengcount]'] = 'wanchengcount';
        if(this.sortdatas.status_name != ''){
          param['searchParams[status_sort]'] = this.sortdatas.status_name;
        }
        if(this.sortdatas.ctime != ''){
          param['searchParams[ctime_sort]'] = this.sortdatas.ctime;
        }
        if(this.sortdatas.request_time != ''){
          param['searchParams[request_time_sort]'] = this.sortdatas.request_time;
        }
        if(this.form.stock != ""){
          param['searchParams[stock]'] = this.form.stock;
        }
        getList(param).then(res => {
          this.loading = false;
          this.production_dispatch_control = res.msg.production_dispatch_control;
          this.production_execut_properly = res.msg.production_execut_properly;
          this.production_dispatch_accomplish = res.msg.production_dispatch_accomplish;
          this.setdata(res.msg.instruct,this.tableData,1);
          this.pagintion.total = parseInt(res.msg.total);
          this.countdata.zongshu = res.msg.zongshu;
          this.countdata.wanchengcount = res.msg.wanchengcount;
          this.countdata.weiwanchengcount = res.msg.weiwanchengcount;
        }, err => {
          this.loading = false;
        })
      },
      //解析数据
      setdata(data,tableData,code) {
        var row = 0;
        var index = 0;
        if(code == 1){
          this.objectSpandata = {};
        }
        if(code == 2){
          this.priobjectSpandata = {};
        }
        tableData.length = 0;
        for (var i = 0; i < data.length; i++) {
          var databean = {};
          var bean = data[i];
          if (i != 0) {
            var obean = data[i - 1];
            if (obean.id == bean.id) {
              if(code == 2){
                if(bean.color != null && bean.color.length > 5){
                  row = row + 2;
                }else{
                  row++;
                }
              }
              if(code == 1){
                row++;
              }
              databean.isshou = false;
            } else {
              databean.isshou = true;
              index = i;
            }
          } else {
            databean.isshou = true;
            index = i;
            if(code == 2){
              if(bean.color != null && bean.color.length > 5){
                row = row + 2;
              }else{
                row++;
              }
            }
            if(code == 1){
              row++;
            }
          }
          if (i < data.length - 1) {
            var nbean = data[i + 1];
            if (nbean.id != bean.id) {
              if(code == 2){
                this.priobjectSpandata[index] = row;
              }
              if(code == 1){
                this.objectSpandata[index] = row;
              }
              row = 1;
            }
          } else {
            if(code == 2){
              this.priobjectSpandata[index] = row;
            }
            if(code == 1){
              this.objectSpandata[index] = row;
            }
            row = 1;
          }
          
          databean.id = bean.id;
          databean.status = bean.status;
          switch (bean.status) {
            case "1":
              databean.status_name = "新任务";
              break;
            case "2":
              databean.status_name = "未送料";
              break;
            case "3":
              databean.status_name = "请求送料";
              break;
            case "4":
              databean.status_name = "送料中";
              break;
            case "5":
              databean.status_name = "已收料";
              break;
          }
          if(bean.batch_names != null){
            databean.batch_names = bean.batch_names.split(",");
          }
          if(bean.stock == '0'){
            databean.stock_name = '未备料';
          }else if(bean.stock == '1'){
            databean.stock_name = '已备料';
          }
          databean.machine_number = bean.machine_number;
          databean.color = bean.color;
          databean.color_code = bean.color_code;
          databean.go_on = bean.go_on;
          databean.yhh_id = bean.yhh_id;
          if(bean.isyhh == 1){
            databean.yhh_id = "";
          }
          databean.amount = bean.amount;
          databean.count = bean.sum;
          databean.heap_number = bean.heap_number;
          // databean.remark = bean.remark;
          databean.workshop = bean.workshop;
          databean.square = bean.square;
          console.log(bean.yhh_remark);
          databean.remark = bean.yhh_remark;
          databean.thickness = bean.thickness;
          databean.creator_name = bean.creator_name;
          databean.feed_name = bean.feed_name;
          databean.reap_name = bean.reap_name;
          databean.guige = bean.guige;
          databean.ctime = this.getdate(bean.ctime);
          databean.request_time = this.getdate(bean.request_time);
          databean.accomplish_time = this.getdate(bean.accomplish_time);
          databean.productive_time = this.getdate(bean.productive_time);
          var date = new Date(date);
          tableData.push(databean);
        }
      },
      //修改机台号
      alfter_machine_number(){
        var datas = this.$refs.formtable.selection;
        var param = {};
        var plmd_ids = [];
        if(datas.length === 0){
          this.$confirm('必须勾选任务')
              .then(_ => {
                done();
              })
              .catch(_ => {});
          return;
        }
        for(var i = 0 ;i < datas.length ;i++){
          plmd_ids[i] = datas[i].id;
        }
        param.plmd_ids = plmd_ids;
        param.machine_number = this.machine_number;
        post_machine_number(param).then(res => {
          this.getplmlist();
        })
      },

      getdate(date){
        if(date == null || date == ""){
          return "";
        }
        date = parseInt(date)*1000;
        var date = new Date(date);
        var YY = date.getFullYear() + '-';
        var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
        var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
        var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
        var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
        return YY + MM + DD +" "+hh + mm + ss;
      }
    },

  }
</script>
